package com.analytical.www.base

import android.app.Application
import com.analytical.www.component.SoundPoolManager
import java.util.*

/**
 *@Auther Shawn
 *创建时间：2023/12/24 12:30
 */
class AppBase:Application() {
    companion object {
        lateinit var instance: AppBase
    }
    private var appFragList = LinkedList<FragmentBase>()
    override fun onCreate() {
        super.onCreate()
        instance = this
        SoundPoolManager.init(this)
    }

    fun addFrag(frag: FragmentBase) {
        appFragList.add(frag)
    }

    fun removeFrag(frag: FragmentBase) {
        appFragList.remove(frag)
    }

    fun dispatcherOnKeyCodeBack(): Boolean {
        for (i in appFragList.indices.reversed()) {
            if (appFragList[i].onKeyCodeBack()) {
                return true
            }
        }
        return false
    }
}